package com.mytest.example.gobrs.task.chain2;

import com.gobrs.async.TaskSupport;
import com.gobrs.async.anno.Task;
import com.gobrs.async.task.AsyncTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Task(failSubExec = true)
@Component
public class Chain2TaskA extends AsyncTask<Chain2Param1, String> {
    @Override
    public void prepare(Chain2Param1 o) {

    }

    @Override
    public String task(Chain2Param1 o, TaskSupport taskSupport) {
        log.info("Chain2TaskA uid={}", o.getUid());
        return "Chain2TaskA";
    }

    @Override
    public boolean nessary(Chain2Param1 o, TaskSupport taskSupport) {
        return true;
    }

    @Override
    public void onSuccess(TaskSupport taskSupport) {
        log.info("Chain2TaskA 执行完成");
        //如果当前任务执行成功后，里立即想执行一些操作，可以在此回调实现，如发送短信，消息通知等

    }

    @Override
    public void onFail(TaskSupport taskSupport) {
        log.error("Chain2TaskA 执行失败");
    }
}
